package com.spzx.common.exception;

import com.spzx.model.vo.common.ResultCodeEnum;
import lombok.Data;


/**
 * 自定义异常
 * Project: spzx-parent
 * Package: com.spzx.common.exception
 * Version: 1.0
 * <p>
 * Created by  wangjiaxin  on 2023/11/30 22:59
 */
@Data
public class MyException extends RuntimeException {
    private static final long serialVersionUID = 4206528554501240807L;
    private Integer code;          // 错误状态码
    private String message;        // 错误消息

    private ResultCodeEnum resultCodeEnum;     // 封装错误状态码和错误消息

    public MyException(ResultCodeEnum resultCodeEnum) {
        this.resultCodeEnum = resultCodeEnum;
        code = resultCodeEnum.getCode();
        message = resultCodeEnum.getMessage();
    }

    public MyException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
